<?php $this->load->view('header', array('data' => $data));?>
<div id="center">
	<div id="left_box">
		<div class="module"><div class="text">权限管理</div></div>
		<div class="sub_module">
		<ul class="sub_module">
		<?php foreach ($data['module'][$data['current']['module']]['sub_module'] as $v) { ?>
			<li <?php if ($v['ename'] == $data['current']['sub_module']) echo "class='current'"; ?> ><a href="<?php echo "/{$data['current']['module']}/{$v['ename']}";?>"><?php echo $v['cname'];?></a></li>
		<?php }?>
		</ul>
		</div>
		<div class="desc_box1 desc_box">
			<div class="title"></div>
			<div class="content"></div>
		</div>
		<div class="desc_box2 desc_box">
			<div class="title"></div>
			<div class="content"></div>
		</div>
	</div>
	<div id="right_box">
		<fieldset id="group">
			<legend>选择要编辑的角色</legend>
			<select name="role_id">
				<option value="0">请选择</option>
				<?php foreach ($data['all_role'] as $g) {?>
				<option value="<?php echo $g['id'];?>"><?php echo $g['role'];?></option>
				<?php } ?>
			</select>
			<input type="button" id="role_button" value="确定" />
		</fieldset>
<?php if ($data['flag']) {?>
		<fieldset id="info">
			<legend>角色信息</legend>
			<form action="/priv/redit_info/" method="post" id="redit_info_form">
			<input type="hidden" name="role_id" value="<?php echo $data['role']['id']; ?>" />
			<table>
				<tr>
					<td class="col1">角色名</td>
					<td class="col2"><input type="text" id="role" name="role" value="<?php echo $data['role']['role'];?>" size="30" /></td>
					<td class="col3"><div id="role_msg"></div></td>
				</tr>
				<tr>
					<td class="col1">备注</td>
					<td class="col2"><textarea name="remark" id="remark" cols="30" rows="5"><?php echo $data['role']['remark'];?></textarea></td>
					<td class="col3"><div id="remark_msg"></div></td>
				</tr>
				<tr>
					<td class="col1"><input type="submit" value="修改" /><input type="reset" value="重置" /></td>
					<td class="col2" colspan="2"></td>
				</tr>
			</table>
			</form>
		</fieldset>
		<fieldset id="priv">
			<legend>角色权限</legend>
			<fieldset class="no_res">
				<legend>非资源权限</legend>
				<table>
				<?php foreach ($data['module_tree'] as $v) {?>
				<?php if ($v['atype_1'] == 0) {continue;} ?>
					<tr>
						<td class="col1"><?php echo $v['module_cname']; ?></td>
						<td class="col2">
							<ul>
							<?php foreach ($v['sub'] as $kk => $vv) { ?>
							<?php if ($vv['atype'] == 1) {?>
								<li><input class="priv" value="<?php echo "{$data['role']['id']}_{$kk}_0";?>" type="checkbox" <?php if (in_array($kk, $data['no_res'])) {echo "checked='checked'";} ?>/><?php echo $vv['sub_module_cname']; ?></li>
							<?php } ?>
							<?php } ?>
							</ul>
						</td>
					</tr>
				<?php } ?>
				</table>
			</fieldset>
			<fieldset class="res">
				<legend>资源权限</legend>
				<table>
					<tr>
					<th class="col1">资源</th>
					<th class="col2">权限</th>
					</tr>
				<?php foreach ($data['module_tree'] as $v) {?>
				<?php if ($v['atype_2'] == 0) {continue;} ?>
					<tr>
						<td class="col1">个人资源</td>
						<td class="col2">
							<fieldset>
								<legend><?php echo $v['module_cname'];?></legend>
							<?php foreach ($v['sub'] as $kk => $vv) { ?>
								<ul>	
									<li><input class="priv" value="<?php echo "{$data['role']['id']}_{$kk}_1";?>" type="checkbox" <?php if (in_array($kk, $data['person_res'])) {echo "checked='checked'";} ?>/><?php echo $vv['sub_module_cname']; ?></li>
								</ul>	
							<?php } ?>
							</fieldset>
						</td>
					</tr>
				<?php } ?>
				<?php foreach ($data['module_tree'] as $v) {?>
				<?php if ($v['atype_2'] == 0) {continue;} ?>
					<tr>
						<td class="col1">全部资源</td>
						<td class="col2">
							<fieldset>
								<legend><?php echo $v['module_cname'];?></legend>
							<?php foreach ($v['sub'] as $kk => $vv) { ?>
								<ul>	
									<li><input class="priv" value="<?php echo "{$data['role']['id']}_{$kk}_2";?>" type="checkbox" <?php if (in_array($kk, $data['all_res'])) {echo "checked='checked'";} ?>/><?php echo $vv['sub_module_cname']; ?></li>
								</ul>	
							<?php } ?>
							</fieldset>
						</td>
					</tr>
				<?php } ?>
				</table>
			</fieldset>
		</fieldset>
<?php } ?>
	</div>
</div>
<?php $this->load->view('footer') ?>
